import { useState,useEffect } from "react";
import {useParams} from 'react-router-dom'

export default function Category() {
    var [n, setN] = useState(10);
    var [arr,setarr] = useState([1,2,3,4])
    var params = useParams()
    var [data,setData] = useParams()

    function add() {
        n++;
        setN(n)
    }
    function set(){
        arr.push(5)
        setarr([...arr])
    }
    // 路由参数发生变化，自动调用
    useEffect(() => {
        console.log('变化');
       console.log(params);
    });
    return (
        <div className="container">
            <div>
                <p onClick={add}>{n}</p>
                <p onClick={set}>{arr}</p>
            </div>
        </div>

    )
}